package com.pxml2pdf.pdf.Node;

import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfContentByte;

public class LiLabelNode extends BaseNode {

	private static final String RECORD_STATUS = "Record status";
	protected static Font font_RS;
	static {
		font_RS = new Font();
		font_RS.setStyle(Font.BOLD);
		font_RS.setColor(99, 99, 99);
		font_RS.setFamily("Arial, Helvetica, sans-serif");
	}

	@Override
	public void drawingBox(PdfContentByte cb) {

	}

	@Override
	public void fillValue(PdfContentByte cb, Font font) throws DocumentException {
		String str = getValue().trim();
		//System.out.println(str);
		String rs = RECORD_STATUS;
		str = str.replace(RECORD_STATUS, "");
		int pos = str.lastIndexOf(STAR);
		if (pos >= 0) {
			String strB = str.substring(0, pos);
			str = str.substring(pos + 1);
			font_RS.setSize(font.getSize());
			FONT_STAR.setSize(font.getSize());
			ColumnText ct = new ColumnText(cb);
			ct.setSimpleColumn(getLlx(), getLly(), getUrx(), getUry(), LEADING, getAlign());
			ct.addText(new Phrase(rs, font_RS));
			ct.addText(new Phrase(strB, font));
			ct.addText(new Phrase(STAR, FONT_STAR));
			ct.addText(new Phrase(str, font));
			ct.go();
		}
	}

}
